using System;
using Gtk;

using MySql.Data.MySqlClient;

public partial class MainWindow : Gtk.Window
{
	private MySqlConnection connection;
	
	public MainWindow () : base(Gtk.WindowType.Toplevel)
	{
		Build ();
		
		connection = new MySqlConnection("Server=localhost;Database=dbalejandro;Uid=root;Pwd=sistemas");
		
		connection.Open();
		
		//leer...
		MySqlCommand command = connection.CreateCommand();
		command.CommandText = "select * from libro";
		
		MySqlDataReader dataReader = command.ExecuteReader();
		for (int index=0; index < dataReader.FieldCount; index++)
			Console.WriteLine("columna {0}={1}", index, dataReader.GetName(index));
		
		while (dataReader.Read()) {
			//procesar cada fila
			Console.WriteLine("Libro-----------");
			for (int index=0; index < dataReader.FieldCount; index++)
				Console.WriteLine("valor columna {0}={1}", index, dataReader[index]);
		}
		
		dataReader.Close();
		//...fin leer
		
		connection.Close();
		
	}

	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
	{
		Application.Quit ();
		a.RetVal = true;
	}
}
